<template>
    <!-- mine/pages/myFeedback/myFeedback.wxml -->
    <view :style="objColor">
        <!-- 选项卡 -->
        <view class="tabs">
            <tabs :tabMenu="tabMenu" @checkIndex="checkIndex"></tabs>
        </view>
        <!-- 反馈 -->
        <view v-if="myFeedBackList.length || myFeedBackList2.length">
            <view v-if="tabsIndex == 1">
                <view class="myFeedBackList" v-for="(item, index) in myFeedBackList" :key="index">
                    <view class="title">{{ item.typeName }}</view>

                    <view class="content-wrap">
                        <text class="content">{{ item.feedbackContent }}</text>
                        <text class="more" @tap="toFeedbackDetails" :data-id="item.id">查看更多 ></text>
                    </view>

                    <view class="time">{{ item.createTime }}</view>

                    <view class="reply-wrap" v-if="item.customerServiceReply">
                        <text class="reply">客服回复:</text>
                        <text>{{ item.customerServiceReply }}</text>
                    </view>
                </view>
            </view>
            <view v-if="tabsIndex == 0">
                <view class="myFeedBackList" v-for="(item, index) in myFeedBackList2" :key="index">
                    <view class="title">{{ item.typeName }}</view>

                    <view class="content-wrap">
                        <text class="content">{{ item.feedbackContent }}</text>
                        <text class="more" @tap="toFeedbackDetails" :data-id="item.id">查看更多 ></text>
                    </view>

                    <view class="time">{{ item.createTime }}</view>
                </view>
            </view>
            <loding :loading="loading" :noMore="noMore" />
            <!-- <view wx:if="noMore">没有更多了</view> -->
        </view>
        <Upgrading text="暂无内容" v-if="!myFeedBackList.length && tabsIndex == 1"></Upgrading>
        <Upgrading text="暂无内容" v-if="!myFeedBackList2.length && tabsIndex == 0"></Upgrading>
    </view>
</template>

<script>
'use strict';
import tabs from '../../../components/tabs/tabs';
import Upgrading from '../../../components/upgrading/upgrading';
import loding from '../../../components/loading/loading';

// exports.__esModule = true; // mine/pages/myFeedback/myFeedback.ts

var https_1 = require('./../../../api/https.js');
export default {
    components: {
        tabs,
        Upgrading,
        loding
    },
    data() {
        return {
            tab: 1,
            noMore: false,
            feedbackListConfig: {
                state: 1,
                current: 1,
                size: 10
            },
            feedbackListConfig2: {
                state: 0,
                current: 1,
                size: 10
            },
            tabMenu: ['已处理', '未处理'],
            myFeedBackList: [],
            myFeedBackList2: [],
            tabsIndex: 1,
            fileList: [
                {
                    url: 'https://img.yzcdn.cn/vant/leaf.jpg'
                },
                {
                    url: 'https://img.yzcdn.cn/vant/tree.jpg',
                    deletable: false
                }
            ],
            loading: false
        };
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function () {
        this.getMyFeedbackList(1);
        this.getMyFeedbackList(0);
    },
    onPullDownRefresh: function () {
        setTimeout(function () {
            uni.stopPullDownRefresh();
        }, 2000);
    },
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        this.getMyFeedbackList(this.tabsIndex);
    },
    methods: {
        // 获取反馈列表
        getMyFeedbackList: function (type) {
            if (type === void 0) {
                type = 1;
            }

            var that = this;
            var _a = this;
            var feedbackListConfig = _a.feedbackListConfig;
            var feedbackListConfig2 = _a.feedbackListConfig2;
            var config = feedbackListConfig;

            if (type == 0) {
                config = feedbackListConfig2;
            }

            var listName = 'myFeedBackList';

            if (type == 0) {
                listName = 'myFeedBackList2';
            }

            this.loading= true
            https_1.getMyFeedbackList(config).then(function (res) {
                var _a;

                if (res.code == 0) {
				
					if(listName==='myFeedBackList'){
					
						that.setData({
						  myFeedBackList: [...that.myFeedBackList, ...res.data.records],
						  loading: false,
						  noMore: res.data.records.length === 0
						})
						
					}else{
						that.setData({
						  myFeedBackList2: [...that.myFeedBackList2, ...res.data.records],
						  loading: false,
						  noMore: res.data.records.length === 0
						})
					}
					
                    config.current++;
					
					
                }
            });
        },

        toFeedbackDetails: function (e) {
            var id = e.currentTarget.dataset.id;
            uni.navigateTo({
                url: '/homeSub/pages/feedbackDetails/feedbackDetails?id=' + id
            });
        },

        checkIndex: function (e) {
            var tabsIndex = e.detail;
			console.log(tabsIndex)
            if (tabsIndex == 0) {
                tabsIndex = 1;
            } else {
                tabsIndex = 0;
            }

            this.tabsIndex=tabsIndex
        }
    }
};
</script>
<style lang="less">
@import url('./myFeedback.less');
</style>
